/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin		 	*/
/*	Project:	GoLib-1.0.0			*/
/*	Author:		gong_libin			*/
/*	Date:		2016_01_01			*/
/*	File:		GoMapTest.go			*/
/********************************************************/

package main

import (
	. "GoGlb"
	C "GoCap"
)

func main() {
	m := new(C.GoMap)
	m.GoMapCreate(20)

	for i := 0; i < 20; i ++ {
		m.GoMapInsert(i, i + 100)
	}
	show(m)

	m.GoMapUpdate(8, 208)
	find(m, 8)
	m.GoMapDelete(8)
	find(m, 8)
}

func find(m *C.GoMap, k int) {
	v, b := m.GoMapSelect(k)
	if true == b {
		GoPrint("Found %d = %d\n", k, v)
	} else {
		GoPrint("Not found %d\n", k)
	}
}

func show(m *C.GoMap) {
	for k, v := range *m.GoMapHandle() {
		GoPrint("%04d -> %04d\n", k, v)
	}
}
